﻿using System;
using System.Collections.Generic;
using System.Linq;
using Assist;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Revit;

namespace YArchitech.Plumbing
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class FilterTheSelectedCommand : HYExternalCommand
	{
		public override Result HYExecute(ref string TranName)
		{
			TranName = "过滤选择";
			if (base.Sel.GetElementIds().Any<ElementId>())
			{
				new FormFilterTheSelected(base.Doc, base.Sel).ShowDialog();
			}
			else
			{
				IList<Element> list;
				do
				{
					list = base.Sel.PickElementsByRectangle();
				}
				while (list.Count <= 0);
				RevitVersionFuncs.SetSelection(base.Sel, list as List<Element>);
				new FormFilterTheSelected(base.Doc, base.Sel).ShowDialog();
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
